﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace HoldemView
{
    public partial class GameForm : Form
    {
        public HoldemTable TableView { get { return this.pnlTable; } }
        
        public ToolStrip DebugStrip { get { return tsDebug; } }

        public MenuStrip MenuStrip { get { return msMainMenu; } }

        public HoldemTableDirector Director {get;set;}

        public TextWriter Console {get;set;}

        public GameForm()
        {
            InitializeComponent();
            //this.ResizeToFit();
            Console = new Layers.UI.TextBoxWriter(this.tbLog);
            StreamWriter strm = new StreamWriter("Game.log");
            strm.AutoFlush = true;
            Layers.MyLogger.DefaultWriter = new Layers.DupTextWriter(Console, strm);
        }

        public void ResizeToFit()
        {
            // TODO
            Rectangle bounds = new Rectangle(int.MaxValue,int.MaxValue,0,0);
            foreach (Control c in this.pnlTable.Controls)
            {
                if (c.Left < bounds.Left)
                    bounds.X = c.Left;
                if (c.Top < bounds.Top)
                    bounds.Y = c.Top;
                if (c.Right > bounds.Right)
                    bounds.Width = c.Right - bounds.Left;
                if (c.Bottom > bounds.Bottom)
                    bounds.Height= c.Bottom - bounds.Top;
            }
            //bounds.Inflate(bounds.Left, bounds.Top);
            this.Size = bounds.Size;
            Refresh();
        }
               
    }
}
